package com.zdsoft.crm.service.auth.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zdsoft.crm.dao.auth.ISysRoleMapper;
import com.zdsoft.crm.entity.auth.SysRole;
import com.zdsoft.crm.service.auth.ISysRoleService;
import com.zdsoft.crm.vo.PageVo;

@Service
@Transactional
public class SysRoleServiceImpl implements ISysRoleService{

	
	@Autowired
	ISysRoleMapper dao;
	/**
	 * 分页
	 */
	@Override
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(dao.pageList(beginIndex, endIndex));
		// pageVo.setList(dao.pageList((pageNum - 1) * pageSize, pageSize));
		// mysql
		// pageVo.setList(dao.pageList(pageNum, pageSize));
		pageVo.setTotalCount(dao.totalCount().intValue());
		return pageVo;
	}

	@Override
	public SysRole findById(String id) {
		
		return dao.findById(id);
	}

	//添加
	@Override
	public int save(SysRole sysRole) {
		return dao.save(sysRole);
	}
	//删除
	@Override
	public int deleteRole(String id) {
		return dao.deleteById(id);
	}
	//修改
	@Override
	public int update(SysRole sysRole) {
		return dao.update(sysRole);
	}

	
	//查询所有
	@Override
	public List<SysRole> findAll() {
		
		return dao.select();
	}

}
